import json


class GoodsBase(object):
    _id: str
    code: str
    applet_id: str
    img_url: str
    name: str
    category: str
    sale_num: str
    price: str
    spec: str
    state: str
    create_time: str
    edit_url: str

    def __init__(self, _id, code, applet_id, img_url, name, category, sale_num, price, spec, state, create_time, edit_url):
        self._id = _id
        self.code = code
        self.applet_id = applet_id
        self.img_url = img_url
        self.name = name
        self.category = category
        self.sale_num = sale_num
        self.price = price
        self.spec = spec
        self.state = state
        self.create_time = create_time
        self.edit_url = edit_url

    def to_dict(self):
        return {
            '_id': self._id,
            "code": self.code,
            'applet_id': self.applet_id,
            "img_url": self.img_url,
            "name": self.name,
            "category": self.category,
            "sale_num": self.sale_num,
            "price": self.price,
            "spec": self.spec,
            'state': self.state,
            'create_time': self.create_time,
            'edit_url': self.edit_url
        }

    def to_json(self):
        return json.dumps(self.to_dict(), indent=4, ensure_ascii=False)
